<?php
require_once("ClasseBanco.php");

/**
 * Classe fornecedor
 *
 * @author jorge
 * @version 1.0
 *
  "FCODI"	 CHAR(20) NOT NULL,
  "FNOME"	 CHAR(60),
  "FENDE"	 CHAR(40),
  "FCEP"	 CHAR(9),
  "FCIDA"	 CHAR(15),
  "FESTA"	 CHAR(2),
  "FEMAIL"	 CHAR(60),
  "FTELE"	 CHAR(30),
  "FFAX"	 CHAR(30),
  "FCONT"	 CHAR(40),
  "FCGC"	 CHAR(18),
  "FINSCE"	 CHAR(15),
  "FINSCM"	 CHAR(15),
  "FOUTR"	 CHAR(15),
  "FOBSE"	 CHAR(60),
  "FPAIS"	 CHAR(20),
  "FBAIRRO"	 CHAR(20),
  "FREGIAO"	 CHAR(4),
 *
 */
class forneced 
{
    public $_fcodi;
    public $fnome;
    public $fende;
    public $fcep;
    public $fcida;
    public $festa;
    public $femail;
    public $ftele;
    public $ffax;
    public $fcont;
    public $fcgc;
    public $finsce;
    public $finscm;
    public $foutr;
    public $fobse;
    public $fpais;
    public $fbairro;
    public $fregiao;

    function __construct($_fcodi, $fnome, $fende, $fcep, $fcida, $festa, $femail, $ftele, $ffax, $fcont, $fcgc, $finsce, $finscm, $foutr, $fobse, $fpais, $fbairro, $fregiao) {
        $this->_fcodi = $_fcodi;
        $this->fnome = $fnome;
        $this->fende = $fende;
        $this->fcep = $fcep;
        $this->fcida = $fcida;
        $this->festa = $festa;
        $this->femail = $femail;
        $this->ftele = $ftele;
        $this->ffax = $ffax;
        $this->fcont = $fcont;
        $this->fcgc = $fcgc;
        $this->finsce = $finsce;
        $this->finscm = $finscm;
        $this->foutr = $foutr;
        $this->fobse = $fobse;
        $this->fpais = $fpais;
        $this->fbairro = $fbairro;
        $this->fregiao = $fregiao;
    }

    public function get_fcodi() {
        return $this->_fcodi;
    }

    public function set_fcodi($_fcodi) {
        $this->_fcodi = $_fcodi;
    }

    public function getFnome() {
        return $this->fnome;
    }

    public function setFnome($fnome) {
        $this->fnome = $fnome;
    }

    public function getFende() {
        return $this->fende;
    }

    public function setFende($fende) {
        $this->fende = $fende;
    }

    public function getFcep() {
        return $this->fcep;
    }

    public function setFcep($fcep) {
        $this->fcep = $fcep;
    }

    public function getFcida() {
        return $this->fcida;
    }

    public function setFcida($fcida) {
        $this->fcida = $fcida;
    }

    public function getFesta() {
        return $this->festa;
    }

    public function setFesta($festa) {
        $this->festa = $festa;
    }

    public function getFemail() {
        return $this->femail;
    }

    public function setFemail($femail) {
        $this->femail = $femail;
    }

    public function getFtele() {
        return $this->ftele;
    }

    public function setFtele($ftele) {
        $this->ftele = $ftele;
    }

    public function getFfax() {
        return $this->ffax;
    }

    public function setFfax($ffax) {
        $this->ffax = $ffax;
    }

    public function getFcont() {
        return $this->fcont;
    }

    public function setFcont($fcont) {
        $this->fcont = $fcont;
    }

    public function getFcgc() {
        return $this->fcgc;
    }

    public function setFcgc($fcgc) {
        $this->fcgc = $fcgc;
    }

    public function getFinsce() {
        return $this->finsce;
    }

    public function setFinsce($finsce) {
        $this->finsce = $finsce;
    }

    public function getFinscm() {
        return $this->finscm;
    }

    public function setFinscm($finscm) {
        $this->finscm = $finscm;
    }

    public function getFoutr() {
        return $this->foutr;
    }

    public function setFoutr($foutr) {
        $this->foutr = $foutr;
    }

    public function getFobse() {
        return $this->fobse;
    }

    public function setFobse($fobse) {
        $this->fobse = $fobse;
    }

    public function getFpais() {
        return $this->fpais;
    }

    public function setFpais($fpais) {
        $this->fpais = $fpais;
    }

    public function getFbairro() {
        return $this->fbairro;
    }

    public function setFbairro($fbairro) {
        $this->fbairro = $fbairro;
    }

    public function getFregiao() {
        return $this->fregiao;
    }

    public function setFregiao($fregiao) {
        $this->fregiao = $fregiao;
    }

        
    public function montaFornecedor($condicao) {
        $ba = new bancoDados();
        $sql = $ba->montaSelectSQL($this) . $condicao;
        return $ba->executaQuery($sql);
    }

    public function montaFornecedorConsulta($condicao) {
        $ba = new bancoDados();
        $sql = $ba->montaSelectSQL($this) . $condicao;
        return $ba->executaQueryConsulta($sql);
    }

    public function incluirFornecedor() 
    {
        $ba = new bancoDados();
        $sql = $ba->montaIncluirSQL($this);
        $ba->atualizaQuery($sql);
        return true;
    }

    public function alterarFornecedor() 
    {
	$ba = new bancoDados();
        $sql = $ba->montaAtualizarSQL($this);
	$ba->atualizaQuery($sql);
	return true;
    }

    public function excluirFornecedor() 
    {
	$ba = new bancoDados();
        $sql = $ba->montaExcluirSQL($this);
	$ba->atualizaQuery($sql);
	return true;
    }


    public function XMLFornecedor($cCondicao) 
    {
        $rs = $this->montaFornecedorConsulta($cCondicao);

        header("Content-type:application/xml;");
	$xml = "<?xml version='1.0' encoding='iso-8859-1'?>\r\n";

        global $xml;

	$xml .= "<fornecedores>";

        if ( $rs != '' )
        {
            foreach ($rs as $row)
            {
                    $xml .= "<fornecedor>";
                    $xml .=     "<fcodi>"  . Trim(utf8_encode($row['FCODI']))  . "</fcodi>";
                    $xml .=     "<fnome>"  . Trim(utf8_encode($row['FNOME']))  . "</fnome>";
                    $xml .=     "<fende>"  . Trim(utf8_encode($row['FENDE']))  . "</fende>";
                    $xml .=     "<fcep>"   . Trim($row['FCEP'])   . "</fcep>";
                    $xml .=     "<fcida>"  . Trim($row['FCIDA'])  . "</fcida>";
                    $xml .=     "<festa>"  . Trim($row['FESTA'])  . "</festa>";
                    $xml .=     "<femail>" . Trim($row['FEMAIL']) . "</femail>";
                    $xml .=     "<ftele>" .  Trim($row['FTELE'])  . "</ftele>";
                    $xml .=     "<ffax>"   . Trim($row['FFAX'])   . "</ffax>";
                    $xml .=     "<fcont>"  . Trim(utf8_encode($row['FCONT'])) . "</fcont>";
                    $xml .=     "<fcgc>"   . Trim($row['FCGC'])   . "</fcgc>";
                    $xml .=     "<finsce>" . Trim($row['FINSCE']) . "</finsce>";
                    $xml .=     "<finscm>" . Trim($row['FINSCM']) . "</finscm>";
                    $xml .=     "<foutr>"  . Trim($row['FOUTR'])  . "</foutr>";
                    $xml .=     "<fobse>"  . Trim(utf8_encode($row['FOBSE']))  . "</fobse>";
                    $xml .=     "<fpais>"  . Trim($row['FPAIS'])  . "</fpais>";
                    $xml .=     "<fbairro>". Trim($row['FBAIRRO']). "</fbairro>";
                    $xml .=     "<fregiao>". Trim($row['FREGIAO']). "</fregiao>";
                    $xml .= "</fornecedor>";
            }
        }
	$xml .= '</fornecedores>';
	echo $xml;
        return;
    }
}
?>
